package com.yvtian.admin.service.impl;

import com.yvtian.admin.service.YTDataService;
import org.springframework.stereotype.Service;

import java.time.YearMonth;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class YTDataServiceImpl implements YTDataService {

    @Override
    public Map<String, Object> currEqInfo() {
        Map<String,Object> reqData = new HashMap<>();
        reqData.put("eqName","逆变器");
        reqData.put("monNum",12000);//月度产量
        reqData.put("planNum",300);//计划产量
        reqData.put("actualNum",222);//当前实际产量
        reqData.put("errNum",222);//异常数量
        reqData.put("successNum",222);//成功数量
        reqData.put("failNum",222);//失败数量

        return reqData;
    }

    @Override
    public Map<String,Object> getBottomData() {
        Map<String,Object> reqData = new HashMap<>();

        List<String> xAxisData = new ArrayList<>();
        List<Integer> yAxisData = new ArrayList<>();
        // 获取当前年月
        YearMonth currentYearMonth = YearMonth.now();
        // 获取当月的天数
        int daysInMonth = currentYearMonth.lengthOfMonth();
        for (int i = 1; i <= daysInMonth; i++) {
            xAxisData.add(i + "日");
            double v = Math.random() * 50 + 50;
            yAxisData.add((int) v);
        }
        reqData.put("xAxisData",xAxisData);
        reqData.put("yAxisData",yAxisData);
        return reqData;
    }
}
